#ifndef __TRANSITION_H__
#define __TRANSITION_H__

#include "result.h"
#include "reactiondispatcher.h"

template<class Event, class Destination, class TransitionContext = NoContext<Event>, 
	void (TransitionContext::* pTransitionAction)(const Event&) = NoContext<Event>::NoFunction >
class Transition
{
private:
	template<class State>
	struct Reactions
	{
		static ReactionResult reactWithoutAction(State& st)
		{
			return st.transit<Destination>();
		}

		static ReactionResult reactWithAction(State& st, const Event& evt)
		{
			return st.transit<Destination>(pTransitionAction, evt);
		}
	};

public:
	template<class State, class EventBase, class IdType>
	static ReactionResult react(State& st, const EventBase& evt, const IdType& eventType)
	{
		typedef reactionDispatcher<Reactions<State>, State, EventBase, Event, TransitionContext, IdType> dispatcher;
		return dispatcher::react(st, evt, eventType);
	}

};

#endif
